Class sjl.ReverseRandomIterator
All Packages Class Hierarchy This Package Previous Next Index
Class sjl.ReverseRandomIterator
java.lang.Object
|
+----sjl.Iter
|
+----sjl.ReverseRandomIterator
- public class ReverseRandomIterator
- extends Iter
- implements RandomIterator
ReverseRandomIterator
is an iterator adapter that will traverse
the container in the reverse order of an ordinary
RandomlIterator
.
RandomIterator iter = new ReverseRandomIterator(coll.end());
for (; i.cmp(coll.begin()); i.next()) { ... }
The same functionallity can be found with.
for (RandomIterator iter = coll.rend(); i.cmp(coll.rbegin()); i.next()) { ... }
Any RandomIterator
"iter" can be turned into a reverse
iterator with:
Random reverse_iter = Iter.reverse(iter);
XXX: not true.
Copyright © 1996 Finn Bock
-
ReverseRandomIterator(RandomIterator)
- Construct a new ReverseRandomIterator for the argument iterator.
-
cmp(Iterator)
- Compares two iterators.
-
distance(Iterator)
- Returns the distance from this to the argument iterator.
-
genericCopy()
- Create a copy of this.
-
get()
- Return the value pointed to by the iterator.
-
get(int)
- Return the value pointed to by the iterator.
-
less(Iterator)
- Compares two iterators for reletive order
-
next()
- Advance the iterator to the next element.
-
next(int)
- Advance the iterator to the next element.
-
prev()
- Advance the iterator to the previous element.
-
prev(int)
- Advance the iterator to the previous element.
-
put(int, Object)
- Places a new element in the position pointed to by the iterator.
-
put(Object)
- Places a new element in the position pointed to by the iterator.
-
setTo(Iterator)
- Assign this iterator to another iterator.
ReverseRandomIterator
public ReverseRandomIterator(RandomIterator iter)
- Construct a new ReverseRandomIterator for the argument iterator.
The newly constructed iterator will have a reference to the
argument iterator.
Eqch time next() and prev() is called on the ReverseRandomIterator
the argument iterator is moved back and forward.
- Parameters:
- iter - A RandomIterator.
genericCopy
public Iterator genericCopy()
- Create a copy of this. The copy can be moved without affcection this.
- Returns:
- A new iterator pointing the same element as this.
setTo
public void setTo(Iterator i)
- Assign this iterator to another iterator. This is faster than creating
a new ReverseRandomIterator object.
next
public Iterator next()
- Advance the iterator to the next element. Calls
prev()
on the actual iterator.
prev
public Iterator prev()
- Advance the iterator to the previous element. Calls
next()
on the actual iterator.
next
public RandomIterator next(int n)
- Advance the iterator to the next element. Calls
prev(n)
on the actual iterator.
prev
public RandomIterator prev(int n)
- Advance the iterator to the previous element. Calls
next(n)
on the actual iterator.
get
public Object get()
- Return the value pointed to by the iterator.
get
public Object get(int n)
- Return the value pointed to by the iterator.
put
public Object put(Object o)
- Places a new element in the position pointed to by the iterator.
put
public Object put(int n,
Object o)
- Places a new element in the position pointed to by the iterator.
cmp
public boolean cmp(Iterator i)
- Compares two iterators.
- Returns:
- true if the iterators point to the same position.
less
public boolean less(Iterator i)
- Compares two iterators for reletive order
- Returns:
- true if this iterator is reachable from the argument iterator.
distance
public int distance(Iterator i)
- Returns the distance from this to the argument iterator.
All Packages Class Hierarchy This Package Previous Next Index